package com.study.lambda.basedemo;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2021/5/29 22:05
 */
public class StreamDemo
{
    public static void main(String[] args)
    {
        // int[] arr = {1, 2, 3, 4, 5, 6};
        // double asDouble = IntStream.of(arr).average().getAsDouble();
        // System.out.println(asDouble);
        //
        // int sum = IntStream.of(arr).sum();
        // System.out.println(sum);
        //
        // double[] arr1 = {1, 2, 3, 4, 5, 6};
        // double sum1 = DoubleStream.of(arr1).map(i -> Math.pow(i, 2)).sum();
        // System.out.println(sum1);
        //
        // IntStream.of(1, 2, 3).map(i -> 2 * i).forEach(System.out::println);

        String[] str = {"1", "2"};
        ArrayList<String> list = new ArrayList<>();
        list.add("1");
        list.add("2");
        list.add("3");
        List<String> collect = list.stream().filter(f -> {
            for (String s : str)
            {
                if (s.equals(f))
                {
                    return false;
                }
            }
            return true;
        }).collect(Collectors.toList());
        System.out.println(collect.toString());
    }
}
